package com.bianmaba.dc.bean;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@ToString
public class CollectionRequest implements Serializable {
    private String projectId;
    private String taskId;
    private String executor;

    private String taskInstanceId;
    private String scheduleId;
    private String scheduleName;
    private String description;
    //数据类型:   详细数据=collect_details 统计结果=collect_statistics
    private String dataType;
    private Map<String, String> collectionParameters;

    public CollectionRequest(Map<String, Object> jobData) {
        this.projectId = jobData.getOrDefault(JobParameter.PROJECT_ID.getName(), "").toString();
        this.taskId = jobData.getOrDefault(JobParameter.TASK_ID.getName(), "").toString();
        this.executor = jobData.getOrDefault(JobParameter.EXECUTOR.getName(), "").toString();

        this.taskInstanceId = jobData.getOrDefault(JobParameter.TASK_INSTANCE_ID.getName(), "").toString();
        this.scheduleId = jobData.getOrDefault(JobParameter.SCHEDULE_ID.getName(), "").toString();
        this.scheduleName = jobData.getOrDefault(JobParameter.SCHEDULE_NAME.getName(), "").toString();
        this.description = jobData.getOrDefault(JobParameter.DESCRIPTION.getName(), "").toString();

        collectionParameters = (Map<String, String>) jobData.getOrDefault(JobParameter.COLLECTION_PARAMETER_PARTS.getName(), new HashMap<>());
    }
}
